﻿using System;
using UnityEngine;

namespace Core.Platform
{
    /// <summary>
    /// 原生平台（Android）
    /// </summary>
    public class AndroidPlatform : Component, IAwake, IPlatform
    {
        private AndroidJavaClass jc;
        private AndroidJavaObject jo;

        //渠道
        private string channel;

        public void Awake()
        {
            jc = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
            jo = jc.GetStatic<AndroidJavaObject>("currentActivity");
        }

        public override void Dispose()
        {
            if (IsDisposed) return;
            base.Dispose();
        }

        public void Exit()
        {
            Application.Quit();

        }

        public void CallSdkApi(string api, params string[] args)
        {
            try
            {
                log.err("当前  Channel  " + channel + "  " + api);
                jo.Call(api, args);
            }
            catch (Exception e)
            {
                log.err(e);
            }

        }
    }
}
